<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>海角论坛</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="fly,layui,前端社区">
    <meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
    <link rel="stylesheet" href="../static/res/layui/css/layui.css">
    <link rel="stylesheet" href="../static/res/css/global.css">
</head>
<body>
<meta name="referrer" content="no-referrer">
<div class="fly-header layui-bg-black">
    <div class="layui-container">
        <a class="fly-logo" href="/">
            <img src="../static/res/images/logo.png" alt="layui">
        </a>

        <ul class="layui-nav fly-nav-user" id="ul_user">

            <!-- 登入后的状态 -->
            {%if user%}
            <li class="layui-nav-item">
              <a class="fly-nav-avatar" href="javascript:;">
                <cite class="layui-hide-xs">{{user.nick_name}}</cite>
                <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：南神"></i>
                  {%if user.is_vip != 0%}
                <i class="layui-badge fly-badge-vip layui-hide-xs">VIP{{user.is_vip}}</i>
                  {%endif%}
                <img src="{{user.avatar_url}}">
              </a>
              <dl class="layui-nav-child">
                <dd><a href="/user/set"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
                <dd><a href="/user/follow"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的关注</a></dd>
                <dd><a href="/user/home?u={{user.id}}"><i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a></dd>
                <hr style="margin: 5px 0;">
                <dd><a href="/user/logout" style="text-align: center;">退出</a></dd>
              </dl>
            </li>
            {%else%}
                        <!-- 未登入的状态 -->
            <li class="layui-nav-item">
                <a class="iconfont icon-touxiang layui-hide-xs" href="/login"></a>
            </li>
            <li class="layui-nav-item">
                <a href="/login">登录</a>
            </li>
            <li class="layui-nav-item">
                <a href="/reg">注册</a>
            </li>
            {%endif%}
        </ul>
    </div>
</div>

<div class="fly-panel fly-column">
    <div class="layui-container">
        <ul class="layui-clear">
            {% if num == 1 %}
            <li class="layui-hide-xs layui-this"><a href="">首页</a></li>
            {% else %}
            <li class=""><a href="/">首页</a></li>
            {% endif %}
            {% if num == "tw" %}
            <li class="layui-hide-xs layui-this"><a href="" >提问</a></li>
            {% else %}
            <li><a href="zt?are=tw">提问</a></li>
            {%endif%}
            {% if num == "fx" %}
            <li class="layui-hide-xs layui-this"><a href="">分享</a></li>
<!--?    可以创造红点        <span class="layui-badge-dot"></span>-->
            {% else %}
            <li><a href="zt?are=fx">分享</a></li>
            {% endif %}
            {% if num == "tl" %}
            <li class="layui-hide-xs layui-this"><a href="">讨论</a></li>
            {% else %}
             <li><a href="zt?are=tl">讨论</a></li>
            {% endif %}
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>
            <!-- 用户登入后显示 -->
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="/user/user_message#index">我发表的贴</a></li>
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="/user/collect">我收藏的贴</a>
            </li>
        </ul>

        <div class="fly-column-right layui-hide-xs">
            <a href="/user/add" class="layui-btn">发表新帖</a>
        </div>
        <div class="layui-hide-sm layui-show-xs-block"
             style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
            <a href="/user/add" class="layui-btn">发表新帖</a>
        </div>
    </div>
</div>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8">
            <div class="fly-panel" style="margin-bottom: 0;">

                <ul class="fly-list">
                    {% for i in news.items %}
                    <li>
                        <a href="/user/home?u={{i.user.id}}" class="fly-avatar">
                            <img src="{{i.user.avatar_url}}">
                        </a>
                        <h2>
                            <a class="layui-badge">{{ i.category.name }}</a>
                            <a href="/detail/{{i.id}}">{{ i.title }}</a>
                        </h2>
                        <div class="fly-list-info">
                            <a href="/user/home?u={{i.user.id}}" link>
                                <cite>{{ i.user.nick_name }}</cite>

<!--?                                <i class="iconfont icon-renzheng" title="认证信息：XXX"></i>-->
                                {% if  i.user.is_vip != 0%}
                                <i class="layui-badge fly-badge-vip">VIP{{i.user.is_vip}}</i>
                                {% else %}
                                <i class=""></i>
                                {%endif%}
                            </a>
<!--?                            <span>刚刚</span>-->

                            <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻"><i class="iconfont icon-kiss"></i> {{i.award}}</span>
                            <!--<span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>-->
                            <span class="fly-list-nums">
                <i class="iconfont icon-pinglun1" title="回答"></i> {{i.comment.count()}}
              </span>
                        </div>
                        <div class="fly-list-badge">
                            <!--<span class="layui-badge layui-bg-red">精帖</span>-->
                        </div>
                    </li>
                    {% endfor %}
                </ul>
                <div style="text-align: center">
                    <div style="border-top: 1px dotted #e2e2e2; text-align: center;">

                  <div class="laypage-main">
                      {%if num == 1%}

                      <a href="?page=1" class="laypage-last" title="首页">首页</a>
                      {%if news.has_prev%}
                      <a href="/?page={{news.prev_num}}" class="laypage-prev">上一页</a>
                      {%endif%}
                      <span class="laypage-curr">{{news.page}}</span>
                      {%if news.page + 1 <= news.pages%}
                      <a href="?page={{news.page+1}}">{{news.page + 1}}</a>
                      {%endif%}
                       {%if news.page + 2 <= news.pages%}
                      <a href="?page={{news.page + 2}}">{{news.page + 2}}</a>
                      {%endif%}
                       {%if news.page + 3 <= news.pages%}
                      <a href="?page={{news.page + 3}}">{{news.page + 3}}</a>
                      {%endif%}
                      {%if news.page < news.pages%}
                      <span>…</span>
                      {%endif%}
                      <a href="?page={{news.pages}}" class="laypage-last" title="尾页">尾页</a>
                      {%if news.has_next%}
                      <a href="?page={{news.next_num}}" class="laypage-next">下一页</a>
                        {%endif%}


                      {%elif num == "tw"%}
                     <a href="/zt?are=tw&page=1" class="laypage-last" title="首页">首页</a>
                      {%if news.has_prev%}
                      <a href="/zt?are=tw&page={{news.prev_num}}" class="laypage-prev">上一页</a>
                      {%endif%}
                      <span class="laypage-curr">{{news.page}}</span>
                      {%if news.page + 1 <= news.pages%}
                      <a href="/zt?are=tw&page={{news.page+1}}">{{news.page + 1}}</a>
                      {%endif%}
                       {%if news.page + 2 <= news.pages%}
                      <a href="/zt?are=tw&page={{news.page + 2}}">{{news.page + 2}}</a>
                      {%endif%}
                       {%if news.page + 3 <= news.pages%}
                      <a href="/zt?are=tw&page={{news.page + 3}}">{{news.page + 3}}</a>
                      {%endif%}
                      {%if news.page < news.pages%}
                      <span>…</span>
                      {%endif%}
                      <a href="/zt?are=tw&page={{news.pages}}" class="laypage-last" title="尾页">尾页</a>
                      {%if news.has_next%}
                      <a href="/zt?are=tw&page={{news.next_num}}" class="laypage-next">下一页</a>
                        {%endif%}

                      {%elif num == "fx"%}
                     <a href="/zt?are=fx&page=1" class="laypage-last" title="首页">首页</a>
                      {%if news.has_prev%}
                      <a href="/zt?are=fx&page={{news.prev_num}}" class="laypage-prev">上一页</a>
                      {%endif%}
                      <span class="laypage-curr">{{news.page}}</span>
                      {%if news.page + 1 <= news.pages%}
                      <a href="/zt?are=fx&page={{news.page+1}}">{{news.page + 1}}</a>
                      {%endif%}
                       {%if news.page + 2 <= news.pages%}
                      <a href="/zt?are=fx&page={{news.page + 2}}">{{news.page + 2}}</a>
                      {%endif%}
                       {%if news.page + 3 <= news.pages%}
                      <a href="/zt?are=fx&page={{news.page + 3}}">{{news.page + 3}}</a>
                      {%endif%}
                      {%if news.page < news.pages%}
                      <span>…</span>
                      {%endif%}
                      <a href="/zt?are=fx&page={{news.pages}}" class="laypage-last" title="尾页">尾页</a>
                      {%if news.has_next%}
                      <a href="/zt?are=fx&page={{news.next_num}}" class="laypage-next">下一页</a>
                        {%endif%}

                      {%elif num == "tl"%}
                     <a href="/zt?are=tl&page=1" class="laypage-last" title="首页">首页</a>
                      {%if news.has_prev%}
                      <a href="/zt?are=tl&page={{news.prev_num}}" class="laypage-prev">上一页</a>
                      {%endif%}
                      <span class="laypage-curr">{{news.page}}</span>
                      {%if news.page + 1 <= news.pages%}
                      <a href="/zt?are=tl&page={{news.page+1}}">{{news.page + 1}}</a>
                      {%endif%}
                       {%if news.page + 2 <= news.pages%}
                      <a href="/zt?are=tl&page={{news.page + 2}}">{{news.page + 2}}</a>
                      {%endif%}
                       {%if news.page + 3 <= news.pages%}
                      <a href="/zt?are=tl&page={{news.page + 3}}">{{news.page + 3}}</a>
                      {%endif%}
                      {%if news.page < news.pages%}
                      <span>…</span>
                      {%endif%}
                      <a href="/zt?are=tl&page={{news.pages}}" class="laypage-last" title="尾页">尾页</a>
                      {%if news.has_next%}
                      <a href="/zt?are=tl&page={{news.next_num}}" class="laypage-next">下一页</a>
                        {%endif%}
                      {%endif%}
                  </div>
                    </div>

                </div>

            </div>
        </div>
        <div class="layui-col-md4">


            <div class="fly-panel fly-signin">
                <div class="fly-panel-title">
                    签到
                    <i class="fly-mid"></i>
                    <a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a>
                    <i class="fly-mid"></i>
                    {%if user%}
                    <span class="fly-signin-days">已连续签到<cite>{{user.continuous_sign_in}}</cite>天</span>
                    {%else%}
                    <span class="fly-signin-days">登录后才能签到</span>
                    {%endif%}
                </div>
                <div class="fly-panel-main fly-signin-main">

                 {%if user and user.T_F_sign == 0%}
                    <button class="layui-btn layui-btn-danger" id="LAY_signin">今日签到</button>
                   {%if user.continuous_sign_in < 5%}
                    <span>  可获得<cite>5</cite>飞吻</span>
                    {%elif 5 <= user.continuous_sign_in < 15 %}
                     <span>  可获得<cite>10</cite>飞吻</span>

                     {%elif 15 <= user.continuous_sign_in < 30 %}
                     <span>  可获得<cite>15</cite>飞吻</span>

                     {%elif 30 <= user.continuous_sign_in %}
                     <span>  可获得<cite>20</cite>飞吻</span>
                    {%endif%}

                    {%elif not user%}
                    <span>登录后签到可获得飞吻</span>


                    <!-- 已签到状态 -->
                    {%elif user and user.T_F_sign == 1 %}
                    <button class="layui-btn layui-btn-disabled">今日已签到</button>
                    {%if user.continuous_sign_in < 5%}
                    <span>获得了<cite>5</cite>飞吻</span>
                    {%elif 5 <= user.continuous_sign_in< 15%}
                     <span>获得了<cite>10</cite>飞吻</span>
                   {%elif 15 <= user.continuous_sign_in< 30%}
                     <span>获得了<cite>15</cite>飞吻</span>
             {%elif 30 <= user.continuous_sign_in%}
                     <span>获得了<cite>20</cite>飞吻</span>
                    {%endif%}
                {%endif%}
                </div>
            </div>

            <dl class="fly-panel fly-list-one">
                <dt class="fly-panel-title">本周热议</dt>
                {%for i in tie.items%}
                <dd>
                    <a href="/detail/{{i.id}}">{{i.title}}</a>
                    <span><i class="iconfont icon-pinglun2"></i> {{i.clicks}}</span>
                </dd>
                {%endfor%}
                <!-- 无数据时 -->
                <!--
                <div class="fly-none">没有相关数据</div>
                -->
            </dl>

            <div class="fly-panel">
                <div class="fly-panel-title">
                    分享一个实力Golang教学
                </div>
                <div class="fly-panel-main">
                    <a href="https://www.bilibili.com/video/av65600015" target="_blank" class="fly-zanzhu"
                       time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;">一起go浪</a>
                </div>
            </div>

            <div class="fly-panel fly-link">
                <h3 class="fly-panel-title">友情链接</h3>
                <dl class="fly-panel-main">
                    <dd><a href="https://space.bilibili.com/457643342/" target="_blank">金牌讲师</a>
                    </dd>
                    <dd><a href="http://layim.layui.com/" target="_blank">WebIM</a>
                    </dd>
                    <dd><a href="http://layer.layui.com/" target="_blank">layer</a>
                    </dd>
                    <dd><a href="http://www.layui.com/laydate/" target="_blank">layDate</a>
                    </dd>

                </dl>
            </div>

        </div>
    </div>
</div>

<div class="fly-footer">
    <p><a href="#">海角论坛</a> 2019 &copy; <a href="#">葫芦娃出品</a></p>

</div>

<script src="../static/json/jquery-3.3.1.min.js"></script>
<script src="../static/res/layui/layui.js"></script>
<script src="../static/js/jwt.js"></script>

<script>

    layui.cache.page = '';
    layui.cache.user = {
        username: '游客'
        , uid: -1
        , avatar: '../res/images/avatar/00.jpg'
        , experience: 83
        , sex: '男'
    };

    layui.config({
        version: "3.0.0"
        , base: '../static/res/mods/' //这里实际使用时，建议改成绝对路径
    }).extend({
        fly: 'index'
    }).use('fly');

    layui.use('layer');

    $(function () {

        hasUser();

    });

    function hasUser(){

        let jwt = getJwtToken();
        if (jwt) {
            $.ajax({
                type:"get",
                url: HOST_URL + "user/getUser",
                dataType: "json",
                headers: createAuthorizationTokenHeader(),
                success:function (data) {
                    console.log(data);
                    if (data) {
                        let appendVal = `
                            <li class="layui-nav-item">
                              <a class="fly-nav-avatar" href="javascript:;">
                                <cite class="layui-hide-xs">${data.username}</cite>
<!--                                <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：layui 作者"></i>-->
                                <i class="layui-badge fly-badge-vip layui-hide-xs">VIP${data.level}</i>
                                <img src="${data.picture}">
                              </a>
                              <dl class="layui-nav-child">
                                <dd><a href="user/set.html"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
                                <dd><a href="user/message.html"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a></dd>
                                <dd><a href="user/home.html"><i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a></dd>
                                <hr style="margin: 5px 0;">
                                <dd><a href="javascript:logout();" style="text-align: center;">退出</a></dd>
                              </dl>
                            </li>
                        `;

                        $("#ul_user").html(appendVal);
                    }
                }
            })
        }
    }

    /**
     * 注销
     */
    function logout() {
        layer.confirm("真的要注销吗?", () => {

            removeJwtToken();
            layer.msg("注销成功", {time: 1000}, function () {
                location.reload();
            });
        })
    }

</script>

<script type="text/javascript">
    var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");
    document.write(unescape("%3Cspan id='cnzz_stat_icon_30088308'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "w.cnzz.com/c.php%3Fid%3D30088308' type='text/javascript'%3E%3C/script%3E"));
</script>

</body>
</html>